package com.sevattal.service.leaves.controller;

import com.sevattal.common.base.result.R;
import com.sevattal.service.leaves.entity.Authority;
import com.sevattal.service.leaves.entity.EmpAuthority;
import com.sevattal.service.leaves.entity.vo.EmpAuthorityVo;
import com.sevattal.service.leaves.service.EmpAuthorityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "员工权限管理")
@RestController
@RequestMapping("/admin/leaves/empAuth")
public class EmpAuthorityController {

    @Autowired
    private EmpAuthorityService empAuthorityService;

    @ApiOperation("员工权限查询")
    @GetMapping("get/{id}")
    public R getEmpAuth(@ApiParam(value = "员工ID",required = true) @PathVariable String id){
        List<EmpAuthorityVo> empAuthorityVoList = empAuthorityService.getByEmpId(id);

        return  R.ok().data("authList",empAuthorityVoList);
    }

    @ApiOperation("员工权限授予")
    @PostMapping("authEmp")
    public R authEmp(@ApiParam(value = "员工权限列表",required = true) @RequestBody List<EmpAuthority> empAuthorityList){
        boolean result = empAuthorityService.authEmp(empAuthorityList);
        return R.ok();
    }
}
